package org.sbbs.base.demo.entity;

import jakarta.persistence.Entity;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.sbbs.base.jpa.entity.BaseTreeEntity;

/**
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "base_tree",
		indexes = { 
			@Index(name = "idx_pid_fk", columnList = "pid") 
		})
@Comment("树样例表")
public class BaseTreeBean extends BaseTreeEntity {

////	@Formula("(select count(1)>0 from #{#entityName} t where t.pid=id)")
	@Formula("(select count(1)>0 from base_tree t where t.pid=id)")
	private boolean hasChildren;

	@Transient
	private boolean leaf = false;
        
//public DemoTree(){
//    this.isHasChildren();
//}

}
